package jsu.xxy.coffee3.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import jsu.xxy.coffee3.domain.Material;
import jsu.xxy.coffee3.domain.MaterialNoId;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
* @author 张从轩
* @description 针对表【material】的数据库操作Mapper
* @createDate 2023-06-03 06:27:47
* @Entity jsu.xxy.coffee3.domain.Material
*/
@Mapper
public interface MaterialMapper extends BaseMapper<Material> {

    @Insert("insert into material (mname,mnum) values (#{mname} , #{mnum});")
    void insertMaterial(MaterialNoId materialNoId);

    public Material selectByName(String mname);
    @Insert("insert into material (mname,mnum) values (#{mname} , #{i})")
    public void add(String mname, int i);
    @Update("update material set mnum = mnum - #{comnum} where mid = #{mid}")
    void change(int mid, int comnum);

    List<MaterialNoId> selectByproductId(Integer productid);

    @Update("update material set mnum = mnum + #{mnum} where  mid = #{mid}")
    void changeNums(Integer mid, Integer mnum);
}
